﻿/*
    File name:          Robotarm
    File type:          Class
    Author:             Sune Krog-Meyer 09888
    Creation date:      03-04-2011
    Description:        Contains movementfunktions for the robot.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using i4pro_gruppe_d.ControllerCommunication;
using i4pro_gruppe_d.RobotCommunication;
using i4pro_gruppe_d.SimulatorAdaptor;
using i4pro_gruppe_d.Types;

namespace i4pro_gruppe_d.Hardware
{
    public class Robotarm
    {
        private readonly IControllerCommunication _robotarm;

        /// <summary>
        /// Classconstructor
        /// </summary>
        /// <param name="physical"> True if robot, false if simulator </param>
        public Robotarm(bool physical)
        {
            if(physical)
            {
                _robotarm = new ConcreteDLLAdaptor();           
            }
            else
            {
                _robotarm = new ConcreteSimulatorAdaptor();
            }
        }

        /// <summary>
        /// Moves to a point in a robotvector, possible through another point in a robotvector
        /// </summary>
        /// <param name="vectorName1"> Name of a robotvector </param>
        /// <param name="pointNumber1"> Coordinate pointnumber in the robotvector </param>
        /// <param name="vectorName2"> Name of a robotvector </param>
        /// <param name="pointNumber2"> Coordinate pointnumber in the robotvector </param>
        public void MoveTo(string vectorName1, short pointNumber1, string vectorName2 = null, short pointNumber2 = (short)0)
        {
            Console.WriteLine(_robotarm.moveTo(vectorName1,pointNumber1, vectorName2, pointNumber2) ? "Robotarm MoveTo: Succes" : "Robotarm MoveTo: Failed");
        }

        /// <summary>
        /// Watches the movements of the robot with callbackfunktions
        /// </summary>
        /// <param name="startMotions"> True if watch when movements start, false otherwise </param>
        /// <param name="endMotions"> True if watch when movements stops, false otherwise </param>
        public void WatchMotion(bool startMotions, bool endMotions)
        {
            _robotarm.WatchMotions(startMotions, endMotions);
        }

        /// <summary>
        /// Returns if movement is in progress
        /// </summary>
        /// <returns> True if a new movement can be startet, false otherwise </returns>
        public bool CheckMotionStatus()
        {
            return _robotarm.GetMotionStatus();
        }
    }
}
